//
//  YFLinformationCollectionViewCell.m
//  Music
//
//  Created by dllo on 16/6/13.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "YFLinformationCollectionViewCell.h"

@implementation YFLinformationCollectionViewCell
-(instancetype)initWithFrame:(CGRect)frame
{
    self =[super initWithFrame:frame];
    if (self) {
        
        self.dataArray =[NSMutableArray array];
        self.informationDic =[NSDictionary dictionary];
        
        
        
        
        self.mainScrollView =[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, Screenwidth, Screenheight-64-49-(Screenheight/2-64)-25)];
        //self.mainScrollView.backgroundColor =[UIColor yellowColor];
        
        
        self.informationLabel =[[UILabel alloc]init];
     //   self.informationLabel.backgroundColor =[UIColor greenColor];
        self.informationLabel.text = @"歌手信息";
        [self.mainScrollView addSubview:self.informationLabel];
        
        
        self.detailLabel =[[UILabel alloc]init];
        self.detailLabel.font =[UIFont systemFontOfSize:14];
        self.detailLabel.lineBreakMode = NSLineBreakByTruncatingTail;
      //  self.detailLabel.backgroundColor =[UIColor purpleColor];
        
//        CGSize size = CGSizeMake(Screenwidth-30, MAXFLOAT);
        
        
        self.detailLabel.textAlignment = 0;
        self.detailLabel.numberOfLines = 0;
        self.detailLabel.adjustsFontSizeToFitWidth = YES;
        [self.mainScrollView addSubview:self.detailLabel];
        
        
        self.recodeLabel =[[UILabel alloc]init];
     //   self.recodeLabel.backgroundColor =[UIColor greenColor];
        self.recodeLabel.text = @"档案";
        [self.mainScrollView addSubview:self.recodeLabel];
        
        self.recodeView =[[UIView alloc]init];
      //  self.recodeView.backgroundColor =[UIColor cyanColor];
        [self.mainScrollView addSubview:self.recodeView];
        
        
        
        
        self.experienceLabel =[[UILabel alloc]init];
      //  self.experienceLabel.backgroundColor =[UIColor greenColor];
        self.experienceLabel.text = @"演艺经历";
        [self.mainScrollView addSubview:self.experienceLabel];
        
        self.exDetailLabel =[[UILabel alloc]init];
        self.exDetailLabel.textAlignment = 0;
        self.exDetailLabel.numberOfLines = 0;
        self.exDetailLabel.font =[UIFont systemFontOfSize:14];
        self.exDetailLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        //self.exDetailLabel.adjustsFontSizeToFitWidth= YES;
       //self.exDetailLabel.backgroundColor =[UIColor purpleColor];
        [self.mainScrollView addSubview:self.exDetailLabel];
        
        
        self.rewardLabel =[[UILabel alloc]init];
       // self.rewardLabel.backgroundColor =[UIColor greenColor];
        self.rewardLabel.text = @"获奖记录";
        [self.mainScrollView addSubview:self.rewardLabel];
        
        self.rewardDetailLabel =[[UILabel alloc]init];
        self.rewardDetailLabel.textAlignment = 0;
        self.rewardDetailLabel.numberOfLines = 0;
        self.rewardDetailLabel.font =[UIFont systemFontOfSize:14];
        self.rewardDetailLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        //self.rewardDetailLabel.backgroundColor =[UIColor purpleColor];
        [self.mainScrollView addSubview:self.rewardDetailLabel];
        
        
        self.mainScrollView.delegate =self;
        [self.contentView addSubview:self.mainScrollView];

    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    
    self.informationLabel.frame = CGRectMake(10, 15, 70, 40);
    
    CGSize maximumLabelSize = CGSizeMake(Screenwidth-30, 9999);
    CGSize expectSize = [self.detailLabel sizeThatFits:maximumLabelSize];
    self.detailLabel.frame = CGRectMake(15, self.informationLabel.frame.size.height+20+self.informationLabel.frame.origin.y, expectSize.width, expectSize.height);
    
    self.recodeLabel.frame = CGRectMake(self.detailLabel.frame.origin.x-5, self.detailLabel.frame.origin.y+ self.detailLabel.frame.size.height+15, self.informationLabel.frame.size.width, self.informationLabel.frame.size.height);
    
    self.recodeView.frame = CGRectMake(self.recodeLabel.frame.origin.x+5, self.recodeLabel.frame.origin.y+self.recodeLabel.frame.size.height+15, self.detailLabel.frame.size.width, 500);
    
    
    

    self.experienceLabel.frame = CGRectMake(self.recodeLabel.frame.origin.x, self.recodeView.frame.origin.y+self.recodeView.frame.size.height+15, self.recodeLabel.frame.size.width, self.recodeLabel.frame.size.height);
    
    
    
    CGSize expectSizeEX = [self.exDetailLabel sizeThatFits:maximumLabelSize];
    self.exDetailLabel.frame = CGRectMake(self.detailLabel.frame.origin.x, self.experienceLabel.frame.origin.y+self.experienceLabel.frame.size.height+15, expectSizeEX.width, expectSizeEX.height);
    
    self.rewardLabel.frame = CGRectMake(self.exDetailLabel.frame.origin.x-5, self.exDetailLabel.frame.size.height+self.exDetailLabel.frame.origin.y+15, self.informationLabel.frame.size.width, self.informationLabel.frame.size.height);
    
    CGSize expectSizeX = [self.rewardDetailLabel sizeThatFits:maximumLabelSize];
    self.rewardDetailLabel.frame = CGRectMake(self.rewardLabel.frame.origin.x+5, self.rewardLabel.frame.origin.y+self.rewardLabel.frame.size.height+15, expectSizeX.width, expectSizeX.height);
    
    
    self.mainScrollView.contentSize = CGSizeMake(0, self.informationLabel.frame.size.height+self.detailLabel.frame.size.height+self.recodeView.frame.size.height+self.recodeLabel.frame.size.height+self.experienceLabel.frame.size.height+self.exDetailLabel.frame.size.height+self.rewardLabel.frame.size.height+ self.rewardDetailLabel.frame.size.height+130);
    
    
    NSArray *array =@[@"中文名:",@"外文名:",@"国籍:",@"民族:",@"生日:",@"出生地:",@"身高:",@"体重:",@"血型:",@"毕业于:",@"职业:",@"代表作:"];
    
  //  NSLog(@"==============++++++++++++===========%@",self.informationDic);
    
    for (NSInteger i = 0; i < 12; i++) {
        UILabel *label =[[UILabel alloc]init];
        label.frame = CGRectMake(5, 40*i, 50, 30*2);
        label.font =[UIFont systemFontOfSize:12];
      //  label.backgroundColor =[UIColor redColor];
        label.text = [array objectAtIndex:i];
        [self.recodeView addSubview:label];
    }
    
    for (NSInteger i = 0; i < 12; i++) {
        UILabel *contentLabel =[[UILabel alloc]init];
        contentLabel.textAlignment = 0;
        contentLabel.numberOfLines =0;
        contentLabel.font =[UIFont systemFontOfSize:12];
        contentLabel.frame = CGRectMake(50+10,40*i, 80*3, 30*2);
       // contentLabel.backgroundColor =[UIColor orangeColor];
        
        
        switch (i) {
            case 0:
                
                if ([[self.informationDic objectForKey:@"chineseName"] isEqualToString:@""] ) {
                    
                    contentLabel.text = @"暂无";
                }else{
                    contentLabel.text = [self.informationDic objectForKey:@"chineseName"];
                }
                break;
                
                
            case 1:
                
                NSLog(@"=====================%@",[self.informationDic objectForKey:@"englishName"]);
                //  contentLabel.text = [self.informationDic objectForKey:@"height"];
                
                if ([[self.informationDic objectForKey:@"englishName"] isEqualToString:@""] ) {
                    
                    contentLabel.text = @"暂无";
                }else{
                    contentLabel.text = [self.informationDic objectForKey:@"englishName"];
                }
                break;


            case 2:
                
                NSLog(@"=====================%@",[self.informationDic objectForKey:@"country"]);
                //  contentLabel.text = [self.informationDic objectForKey:@"height"];
                
                if ([[self.informationDic objectForKey:@"country"] isEqualToString:@""] ) {
                    
                    contentLabel.text = @"暂无";
                }else{
                   contentLabel.text = [self.informationDic objectForKey:@"country"];
                }
                break;
            case 3:
                
                NSLog(@"=====================%@",[self.informationDic objectForKey:@"nation"]);
                //  contentLabel.text = [self.informationDic objectForKey:@"height"];
                
                if ([[self.informationDic objectForKey:@"nation"] isEqualToString:@""] ) {
                    
                    contentLabel.text = @"暂无";
                }else{
                    contentLabel.text = [self.informationDic objectForKey:@"nation"];
                }
                break;

            case 4:
                
                NSLog(@"=====================%@",[self.informationDic objectForKey:@"birthDate"]);
                //  contentLabel.text = [self.informationDic objectForKey:@"height"];
                
                if ([self.informationDic objectForKey:@"birthPlace"] != nil ) {
                    
                    contentLabel.text = [self.informationDic objectForKey:@"birthDate"];
                }else{
                    
                }
                break;

                
                
            case 5:
                
                NSLog(@"=====================%@",[self.informationDic objectForKey:@"birthPlace"]);
                //  contentLabel.text = [self.informationDic objectForKey:@"height"];
                
                if ([[self.informationDic objectForKey:@"birthPlace"] isEqualToString:@""] ) {
                    
                    contentLabel.text = @"暂无";
                }else{
                    contentLabel.text = [self.informationDic objectForKey:@"birthPlace"];
                }
                break;
            case 6:
                
                NSLog(@"=====================%@==========",[self.informationDic objectForKey:@"height"]);
                if ([self.informationDic objectForKey:@"height"] != nil) {
                    NSLog(@"这就是null");
                    
                    contentLabel.text =[self.informationDic objectForKey:@"height"];
                }else{
                    contentLabel.text = @"暂无";
                }

                
                
                break;
            case 7:
                
                NSLog(@"=====================%@==============",[self.informationDic objectForKey:@"weight"]);
                if ([self.informationDic objectForKey:@"weight"] != nil) {
                    NSLog(@"这就是null");
                    
                    contentLabel.text =[self.informationDic objectForKey:@"weight"];
                }else{
                   contentLabel.text = @"暂无";
                }
               
                
            break;

            case 8:
                
            if ([[self.informationDic objectForKey:@"bloodType"] isEqualToString:@""] ) {
                    
                    contentLabel.text = @"暂无";
                }else{
                    contentLabel.text = [self.informationDic objectForKey:@"bloodType"];
                }
                break;
            case 9:
                
                NSLog(@"=====================%@",[self.informationDic objectForKey:@"school"]);
                //  contentLabel.text = [self.informationDic objectForKey:@"height"];
                
                if ([[self.informationDic objectForKey:@"school"] isEqualToString:@""] ) {
                    
                    contentLabel.text = @"暂无";
                }else{
                    contentLabel.text = [self.informationDic objectForKey:@"school"];
                }
                break;

            case 10:
                
                NSLog(@"=====================%@",[self.informationDic objectForKey:@"career"]);
                //  contentLabel.text = [self.informationDic objectForKey:@"height"];
                
                if ([[self.informationDic objectForKey:@"career"] isEqualToString:@""] ) {
                    
                    contentLabel.text = @"暂无";
                }else{
                    contentLabel.text = [self.informationDic objectForKey:@"career"];
                }
                break;
            case 11:
                
                NSLog(@"=====================%@",[self.informationDic objectForKey:@"achievements"]);
                //  contentLabel.text = [self.informationDic objectForKey:@"height"];
                
                if ([[self.informationDic objectForKey:@"achievements"] isEqualToString:@""] ) {
                    
                    contentLabel.text = @"暂无";
                }else{
                    contentLabel.text = [self.informationDic objectForKey:@"achievements"];
                }
                break;

                
            default:
                break;
        }
        
        
        
        
        [self.recodeView addSubview:contentLabel];
    }
    

    
    
}

-(void)setModel:(YFLinformationModel *)Model
{
    if (_Model != Model) {
        _Model = Model;
        
        if ([Model.awards isEqualToString:@""]) {
            self.rewardLabel.text = @"暂无相关消息";
        }else{
             self.rewardDetailLabel.text = Model.awards;
        }
        
        
        
        self.detailLabel.text = Model.brief;
       
        if (Model.entertainmentExperience == nil) {
            self.exDetailLabel.text = Model.personalLife;
           
        }if (Model.entertainmentExperience != nil) {
            self.exDetailLabel.text = Model.entertainmentExperience;

        }
        
       
        
        
       
        
    }
    
}


@end
